﻿var xxl = {
    author: "雄大",
    version: "1.0",
    website: "http://localhost:7496/",
    uid:0
}

xxl.xd = {
    setValue: function (key, value) { localStorage.setItem(key, value); },
    getValue: function (key) { return localStorage.getItem(key); }
}

function retRndNum(n) {
    var strnid = "";
    for (var i = 0; i < n; i++) {
        strnid += Math.floor(Math.random() * 10);
    }
    return strnid;
}

/*************************************************************************************************************
cookie操作 
**************************************************************************************************************/
function setCookie(name, value, exptime) {
    if (!exptime) {
        var days = 7; //此 cookie 将被保存 7 天
        exptime = new Date();    //new Date("December 31, 9998");
        exptime.setTime(exptime.getTime() + days * 24 * 60 * 60 * 1000);
    }
    document.cookie = name + "=" + escape(value) + ";path=/;expires=" + exptime.toGMTString();
}

function getCookie(name)//取cookies函数        
{
    var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
    if (arr != null) return unescape(arr[2]); return null;
}

function delCookie(name)//删除cookie
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 5);
    var cval = getCookie(name);
    if (cval != null) document.cookie = name + "=" + cval + ";path=/;expires=" + exp.toGMTString();
}

String.prototype.IsEmail = function () {
    var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
    return reg.test(this);
}

String.prototype.IsMobile = function () {
    var reg = /^1[3|4|5|8]\d{9}$/;
    return reg.test(this);
}

String.prototype.IsDecimal = function () {
    var reg = /^[0-9]+(.[0-9]{1,4})?$/;
    return reg.test(this);
}